#include "vs_opencv.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <openssl/md5.h>

//IplImage *cv_load_image(void *image_data, int image_data_size, unsigned long long image_id)
IplImage *cv_load_image(void *image_data, int image_data_size)
{
	static int magic_count = 0;
    __sync_fetch_and_add(&magic_count, 1);

    CvMat* imagemat = cvCreateMatHeader(1, image_data_size, CV_8UC1);
    cvSetData(imagemat, image_data, image_data_size);
    IplImage* ipl = cvDecodeImage(imagemat, CV_LOAD_IMAGE_UNCHANGED);
    cvReleaseMatHeader(&imagemat);

	return ipl;
}


void cv_release_image(IplImage *img)
{
	if (img)
		cvReleaseImage(&img);
}
